home *** CD-ROM | disk | FTP | other *** search
/ Champak 125 / Vol 125 (Damaged).iso / games / poux.swf / scripts / frame_2 / DoAction.as
Encoding:
Text File  |  2008-11-13  |  5.2 KB  |  211 lines

  1. function resetTiles()
  2. {
  3.    var _loc1_ = this;
  4.    x = 0;
  5.    y = 0;
  6.    while(x < 10)
  7.    {
  8.       while(y < 10)
  9.       {
  10.          duplicateMovieClip("tiles","t" + x + "_" + y,16384 + ++d);
  11.          t = _loc1_["t" + x + "_" + y];
  12.          t._x = x * 28 + 20;
  13.          t._y = y * 28;
  14.          if(y > 5)
  15.          {
  16.             c = int(random(4)) + 1;
  17.             t.col = c;
  18.             t.state = true;
  19.             t.gotoAndStop(c);
  20.             t.x = x;
  21.             t.y = y;
  22.          }
  23.          else
  24.          {
  25.             c = 0;
  26.             t.col = c;
  27.             t.gotoAndStop(5);
  28.             t.x = x;
  29.             t.y = y;
  30.          }
  31.          y++;
  32.       }
  33.       y = 0;
  34.       x++;
  35.    }
  36.    timerID = setInterval(goTime,tc);
  37. }
  38. function findTile(x, y)
  39. {
  40.    var _loc1_ = y;
  41.    var _loc2_ = x;
  42.    var _loc3_ = _root;
  43.    col = _loc3_["t" + _loc2_ + "_" + _loc1_].col;
  44.    if(_loc3_["t" + (_loc2_ - 1) + "_" + _loc1_].col == col or _loc3_["t" + (_loc2_ + 1) + "_" + _loc1_].col == col or _loc3_["t" + _loc2_ + "_" + (_loc1_ - 1)].col == col or _loc3_["t" + _loc2_ + "_" + (_loc1_ + 1)].col == col)
  45.    {
  46.       _loc3_["t" + _loc2_ + "_" + _loc1_].state = false;
  47.       _loc3_["t" + _loc2_ + "_" + _loc1_].gotoAndStop(5);
  48.       sc++;
  49.       tile++;
  50.       if(tile == 20)
  51.       {
  52.          setLevel();
  53.          tile = 0;
  54.       }
  55.       if(_loc3_["t" + (_loc2_ - 1) + "_" + _loc1_].col == col and _loc3_["t" + (_loc2_ - 1) + "_" + _loc1_].state == true)
  56.       {
  57.          findTile(_loc2_ - 1,_loc1_);
  58.       }
  59.       if(_loc3_["t" + (_loc2_ + 1) + "_" + _loc1_].col == col and _loc3_["t" + (_loc2_ + 1) + "_" + _loc1_].state == true)
  60.       {
  61.          findTile(_loc2_ + 1,_loc1_);
  62.       }
  63.       if(_loc3_["t" + _loc2_ + "_" + (_loc1_ - 1)].col == col and _loc3_["t" + _loc2_ + "_" + (_loc1_ - 1)].state == true)
  64.       {
  65.          findTile(_loc2_,_loc1_ - 1);
  66.       }
  67.       if(_loc3_["t" + _loc2_ + "_" + (_loc1_ + 1)].col == col and _loc3_["t" + _loc2_ + "_" + (_loc1_ + 1)].state == true)
  68.       {
  69.          findTile(_loc2_,_loc1_ + 1);
  70.       }
  71.       _loc3_["t" + _loc2_ + "_" + _loc1_].col = 0;
  72.    }
  73. }
  74. function checkTile()
  75. {
  76.    var _loc1_ = _root;
  77.    x = 0;
  78.    y = 0;
  79.    while(x < 10)
  80.    {
  81.       while(y < 9)
  82.       {
  83.          if(_loc1_["t" + x + "_" + (y + 1)].col == 0 and _loc1_["t" + x + "_" + y].col != 0)
  84.          {
  85.             replaceColors(x,y);
  86.             checkTile();
  87.          }
  88.          y++;
  89.       }
  90.       y = 0;
  91.       x++;
  92.    }
  93. }
  94. function replaceColors(px, py)
  95. {
  96.    var _loc1_ = py;
  97.    var _loc2_ = px;
  98.    var _loc3_ = _root;
  99.    c = _loc3_["t" + _loc2_ + "_" + _loc1_].col;
  100.    _loc3_["t" + _loc2_ + "_" + (_loc1_ + 1)].col = c;
  101.    _loc3_["t" + _loc2_ + "_" + (_loc1_ + 1)].state = true;
  102.    _loc3_["t" + _loc2_ + "_" + (_loc1_ + 1)].gotoAndStop(c);
  103.    _loc3_["t" + _loc2_ + "_" + _loc1_].state = false;
  104.    _loc3_["t" + _loc2_ + "_" + _loc1_].col = 0;
  105.    _loc3_["t" + _loc2_ + "_" + _loc1_].gotoAndStop(5);
  106. }
  107. function addScore(x, y)
  108. {
  109.    if(sc > 1)
  110.    {
  111.       textClip.swapDepths(++d);
  112.       textClip._x = x;
  113.       textClip._y = y;
  114.       if(sc < 10)
  115.       {
  116.          score += sc * 100;
  117.          pos = sc * 35;
  118.          textClip.gotoAndPlay(pos);
  119.          clickSound.gotoAndPlay(2);
  120.       }
  121.       else
  122.       {
  123.          score += 2000;
  124.          textClip.gotoAndPlay(350);
  125.          clickSound.gotoAndPlay(5);
  126.       }
  127.    }
  128. }
  129. function setLevel()
  130. {
  131.    level++;
  132.    tc = 30 - level;
  133.    levelUp.gotoAndPlay(2);
  134. }
  135. getURL("FSCommand:allowscale",false);
  136. goTime = function()
  137. {
  138.    var _loc1_ = _root;
  139.    timer--;
  140.    timerBar._height = timer;
  141.    if(timer < 1)
  142.    {
  143.       x = 0;
  144.       while(x < 10)
  145.       {
  146.          y = 1;
  147.          while(y < 10)
  148.          {
  149.             c = _loc1_["t" + x + "_" + y].col;
  150.             _loc1_["t" + x + "_" + (y - 1)].col = c;
  151.             _loc1_["t" + x + "_" + (y - 1)].state = true;
  152.             _loc1_["t" + x + "_" + (y - 1)].gotoAndStop(c);
  153.             _loc1_["t" + x + "_" + y].state = false;
  154.             _loc1_["t" + x + "_" + y].col = 0;
  155.             _loc1_["t" + x + "_" + y].gotoAndStop(5);
  156.             lineSound.gotoAndPlay(2);
  157.             y++;
  158.          }
  159.          if(_loc1_["t" + x + "_" + 0].col != 0)
  160.          {
  161.             gameOver = true;
  162.          }
  163.          x++;
  164.       }
  165.       y = 9;
  166.       x = 0;
  167.       while(x < 10)
  168.       {
  169.          c = int(random(4)) + 1;
  170.          _loc1_["t" + x + "_" + y].col = c;
  171.          _loc1_["t" + x + "_" + y].state = true;
  172.          _loc1_["t" + x + "_" + y].gotoAndStop(c);
  173.          x++;
  174.       }
  175.       if(gameOver == true)
  176.       {
  177.          clearInterval(timerID);
  178.          x = 0;
  179.          while(x < 10)
  180.          {
  181.             y = 0;
  182.             while(y < 10)
  183.             {
  184.                removeMovieClip(_loc1_["t" + x + "_" + y]);
  185.                gameOverClip.gotoAndPlay(2);
  186.                y++;
  187.             }
  188.             x++;
  189.          }
  190.       }
  191.       else
  192.       {
  193.          clearInterval(timerID);
  194.          timerBar._height = tm;
  195.          timer = tm;
  196.          timerID = setInterval(goTime,tc);
  197.       }
  198.    }
  199. };
  200. playing = 1;
  201. level = 1;
  202. tile = 0;
  203. tc = 30;
  204. d = 0;
  205. sc = 0;
  206. score = 0;
  207. timer = tm = 204;
  208. gameOver = false;
  209. resetTiles();
  210. stop();
  211.